public class lk6352{
    public boolean isCircularSentence(String sentence) {
        int n = sentence.length();
        int m=0;
        char ch;
        
        for(int i=0;i<n;i++){
            if(sentence.charAt(i)==' '){
                if(sentence.charAt(i+1)!=sentence.charAt(i-1)){
                    m=1;
                    return false;
                }
            }
            if(i==n-1&&m==0){
                if(sentence.charAt(0)!=sentence.charAt(n-1)){
                    return false;
                }
            }
        }
        return true;
    }
}